package io.renren.modules.generator.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.generator.entity.GameTableEntity;
import io.renren.modules.generator.service.GameTableService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-10-05 11:26:36
 */
@RestController
@RequestMapping("generator/gametable")
public class GameTableController {
    @Autowired
    private GameTableService gameTableService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:gametable:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = gameTableService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:gametable:info")
    public R info(@PathVariable("id") Integer id){
			GameTableEntity gameTable = gameTableService.selectById(id);

        return R.ok().put("gameTable", gameTable);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:gametable:save")
    public R save(@RequestBody GameTableEntity gameTable){
			gameTableService.insert(gameTable);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:gametable:update")
    public R update(@RequestBody GameTableEntity gameTable){
			gameTableService.updateById(gameTable);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:gametable:delete")
    public R delete(@RequestBody Integer[] ids){
			gameTableService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
